//201902104014付饶
package util;

public class Pagination {
    //返回LIMIT子句
    public String toLimitClause(int totalNum){
        //向前台提供元组总数
        this.totalNum=totalNum;
        //计算偏移量
        int offset =(this.pageNo-1)*this.pageSize;
        //输出LIMIT子句
        return " LIMIT "+offset+","+this.pageSize;
    }
    public Pagination(int pageSize,int pageNo){
        //防止错误赋值
        if(pageSize>0){
            this.pageSize=pageSize;
        }else {
            this.pageSize=5;
        }
        if (pageNo>0){
            this.pageNo=pageNo;

        }else {
            this.pageNo=1;
        }

    }
    public int getPageSize(){
        return pageSize;
    }
    public int getPageNo(){
        return pageNo;
    }
    public int getTotalNum(){
        return totalNum;
    }
    private int pageSize=5;
    private int pageNo=1;
    private int totalNum;
}
